import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { EverydayData } from '@/module/everyday-data/entities/everyday-datum.entity';

@Entity()
export class FileUpload {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ nullable: true })
  fileOriginalName: string;

  @Column({ nullable: true })
  aliOSSOriginUrl: string;

  @Column({ nullable: true })
  aliOSSDomainUrl: string;

  @Column({ nullable: true })
  totalNumber: number;

  @Column({
    type: 'json',
    nullable: true,
  })
  otherNumber: any;

  @Column({
    type: 'date',
    nullable: true,
  })
  uploadDate: Date;

  @Column({
    type: 'time',
    nullable: true,
  })
  uploadTime: string;

  @ManyToOne(() => EverydayData, (everydayData) => everydayData.fileUploads, {
    onDelete: 'CASCADE',
  })
  @JoinColumn()
  everydayData: EverydayData;
}
